package ink.lovejinhu.leetcode;

public class Solution_0485 {

    public int findMaxConsecutiveOnes(int[] nums) {
        int max = 0;
        int length = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 1) {
                length++;
            } else {
                if (length > max) {
                    max = length;
                    length = 0;
                }
            }
        }
        return length < max ? max : length;
    }
}
